﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LibrarySolution.ComMethod
{
    class DataUtil
    {
        public static string getTime()
        {
            DateTime dt = DateTime.Now;
            return dt.ToString("yyyy-MM-dd");
        }

        public static string formattime(string datetime)
        {
            DateTime dt;
            try
            {
                dt = DateTime.Parse(datetime);
                return dt.ToString("yyyy-MM-dd");
            }
            catch (Exception) { return "Wrong"; }

        }

        public static string turnTime(string oldtime,string days)
        {
            int mt;
            DateTime dt;

            dt = DateTime.Parse(oldtime);
            mt = int.Parse(days);
            dt = dt.AddDays(mt);
            return dt.ToString("yyyy-MM-dd");
        }

        public static string addTime(string month)
        {
            string result;
            DateTime dt = DateTime.Now;
            int  mt = int.Parse(month);
            result = DateTime.Now.AddMonths(mt).ToString("yyyy-MM-dd");
            return result;
        }
    }
}
